package com.zr.service;

import java.util.List;

import com.zr.dao.SalaryDao;
import com.zr.model.SalaryModel;

import net.sf.json.JSONObject;

public class SalaryService {
    SalaryDao salarydao= new SalaryDao();
 /**
  * 提供得到所有员工工资的数据的服务
  * @param start
  * @param rows
  * @return
  */
    public JSONObject getAllSalary(int start,int rows){
    	JSONObject jobj= new JSONObject();
		jobj.put("total", salarydao.getAllSalarycount());
    	jobj.put("rows", salarydao.getAllSalary(start, rows));
    	return jobj;
    }
 /**
  * 提供添加员工工资的服务   
  * @param wid
  * @param wname
  * @param did
  * @param month
  * @param salary
  * @param premium
  * @param deduct
  * @return
  */
    public int addSalary(int wid,String wname,int did,int month,String salary,String premium,String deduct){
    	int temp=0;
    	temp=salarydao.addSalary(wid, wname, did, month, salary, premium, deduct);
    	return temp;
    }
 /**
  *  检验用户名是否存在
  * @param tname  传入用户名
  * @return  存在返回true
  */
  public boolean validataWorkerWname(int wid){
		return salarydao.validataWname(wid);
 }
  /**
   * 提供查询一个工人的工资的服务
   * @param wid
   * @param start
   * @param rows
   * @return
   */
  public JSONObject selectOneWorkerSalary(int wid,int start,int rows){
	  JSONObject jobj= new JSONObject();
	  jobj.put("total", salarydao.SelectOneSalarycount(wid));
	  jobj.put("rows", salarydao.selectOneWorkerSalary(wid,start, rows));
	  return jobj;
  }
  /**
   * 提供修改的服务
   * @param sid
   * @param salary
   * @param premium
   * @param deduct
   * @return
   */
  public int updateSalary(int sid,String salary,String premium,String deduct){
	  int temp=0;
	    temp=salarydao.updateSalary(sid, salary, premium, deduct);
	    return temp;
  }
}
